#include<stdio.h>
#include<string.h>
#define MAX 100

int main()
{
    int n = 0;
    scanf("%d", &n);
    char s1[2][MAX], a1, an;
    int a;
    for (int i = 0; i < n; i++)
    {
        scanf("%s", s1[i]);
        if (strlen(s1[i]) < 10)
            printf("%s\n", s1[i]);
        else
        {
            a1 = s1[i][0];
            a = strlen(s1[i] - 2);
            an = s1[i][strlen(s1[i] - 1)];
            printf("%s%d%s\n", a1, a, an);
        }
    }
    return 0;
}